package com.hunt.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hunt.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Api("板块列表")
@Controller
@RequestMapping("/blockinfo")
public class BlockInfoController extends BaseController{
    @Resource
    private RedisTemplate stringredisTemplate;
    private static final Logger log = LoggerFactory.getLogger(BlockInfoController.class);

    @ApiOperation(value = "板块获取", httpMethod = "GET", produces = "application/json", response = Result.class)
    @ResponseBody
    @RequestMapping(value = "findallblock", method = RequestMethod.GET)
    public Result findideablock() {
    List<JSONObject>list=new ArrayList<>();
    Map<String, String> map =stringredisTemplate.opsForHash().entries("Block_Info");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            list.add(JSON.parseObject(entry.getValue()));
        }
        return Result.success(list);
    }
}

